package com.yit.cn;

/**
 * Created by zhangyanfei on 2019/4/21.
 *
 * @author zhangyanfei
 * @date 2019/04/21
 */
public class PlanB extends AbstractPlan {
    private static final int threshold = 11;

    private SchedulingContext schedulingContext;

    /**
     * 1h/km
     *
     * 0.13t /km/t
     */
    Pilot testyApilot = new Pilot("testyA", 1, 0.13);

    public PlanB(SchedulingContext schedulingContext) {
        super(schedulingContext);
        this.schedulingContext = schedulingContext;

    }

    public Pilot getPilot() {
        schedulingContext.isFly = false;
        schedulingContext.setNormalACanFly(true);
        schedulingContext.setNormalBCanFly(true);
        return testyApilot;
    }

    public boolean condition() {
        if (!schedulingContext.isFly) {
            return false;
        }
        if (!schedulingContext.isNormalACanFly() && !schedulingContext.isNormalBCanFly()) {
            // 累计加班是否超过11
            if (schedulingContext.grandTotalDaysOfA > threshold) {
                return false;
            } else {
                return true;
            }
        }
        return false;
    }

    public String getSFCofDay() {
        if (schedulingContext.getAirplaneModel().equalsIgnoreCase("X")) {
            return "消耗油量：" + schedulingContext.getLoad() * schedulingContext.getDistance() * testyApilot.getSfc()
                + "吨油量;";
        } else {
            return "消耗油量：" + schedulingContext.getLoad() * schedulingContext.getDistance() * 0.12 + "吨油量;";
        }

    }

    public String getElapsedTime() {
        if (schedulingContext.getAirplaneModel().equalsIgnoreCase("X")) {
            return "飞行时间：" + schedulingContext.getDistance() / testyApilot.getFlySpeed() + "h;";
        } else {
            return "飞行时间：" + schedulingContext.getDistance() / (1.15 * testyApilot.getFlySpeed()) + "h;";
        }
    }
}
